{% extends "base.html" %}
{% load opencve_extras %}
{% load crispy_forms_tags %}

{% block title %}Edit Organization - {{ block.super }}{% endblock %}
{% block navbar_title%}Edit Organization{% endblock %}

{% block content %}

<section class="content">
  {% include "messages.html" %}
  <div class="row">
    <div class="col-md-5">
      <div class="box box-primary">
        <div class="box-body">
          {% crispy form %}
        </div>
      </div>
    </div>

    <div class="col-md-7">
      <div class="box box-primary">
          <div class="box-header with-border">
            <h3 class="box-title">New member</h3>
          </div>
          <div class="box-body">
              <div class="row">
              <form action="{% url 'list_organization_members' org_name=request.resolver_match.kwargs.org_name %}" method="post" class="form-inline form-new-member">
                  {% crispy members_form %}
              </form>
                  </div>
          </div>
      </div>
      <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">Members</h3>
          </div>
        <div class="box-body table-responsive no-padding">
            <table class="table table-hover table-striped" id="table-members">
                <tbody>
                <tr>
                    <th>Name</th>
                    <th>Email</th>
                    <th>Role</th>
                    <th></th>
                </tr>
                {% for member in members %}
                <tr>
                    <td>{{ member.user.username }}</td>
                    <td>{{ member.user.email }}</td>
                    {% if member.date_joined %}
                    <td><span class="label label-primary">{{ member.role }}</span></td>
                    {% else %}
                    <td><span class="label label-default">invited</span></td>
                    {% endif %}

                    <td class="pull-right">
                        <div class="btn-group" role="group">
                            <a href="{% url 'delete_organization_member' org_name=request.resolver_match.kwargs.org_name member_id=member.id %}" class="btn btn-danger btn-xs" type="button">Delete</a>
                        </div>
                    </td>
                </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>
      </div>
    </div>
  </div>
</section>

{% endblock %}
